﻿using System;
using System.IO;
using System.Windows;
using DevExpress.Xpf.Ribbon;
using UIT.ScrumTool.Client.View.Admin;
using UIT.ScrumTool.Client.View.Backlog;
using UIT.ScrumTool.Client.View.Project;
using Application = System.Windows.Forms.Application;

namespace UIT.ScrumTool.Client.View.Main
{
    /// <summary>
    /// Interaction logic for windMain.xaml
    /// </summary>
    public partial class windMain : DXRibbonWindow
    {
        //public pageBacklog _pageBacklog = new pageBacklog();

        public static UIElement showPage = new UIElement();
        public static object temp;
        private readonly pageBacklog _pageBacklog = new pageBacklog();
        private readonly uctrlProject _uctrlProject = new uctrlProject();
        //private  readonly uctrlUsers _uctrUsers=new uctrlUsers();

        public windMain()
        {
            InitializeComponent();
            DeleteTempFile();
        }

        // Delete All File In temp Directory
        public static void DeleteTempFile()
        {
            string[] files = Directory.GetFiles(Application.StartupPath + "\\temp");
            foreach (string file in files)
            {
                try
                {
                    File.Delete(file);
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }

        private void gridMain_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                gridMain.Children.Remove(showPage);
                showPage = _pageBacklog;
                gridMain.Children.Add(showPage);
            }
            catch
            {
            }
        }


        private void menuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //gridMain.Children.Add(_pageBacklog);
            }
            catch
            {
            }
        }

        private void menuItemProject_Click(object sender, RoutedEventArgs e)
        {
            gridMain.Children.Remove(showPage);
            showPage = _uctrlProject;
            gridMain.Children.Add(showPage);
        }

        private void menuItemBacklog_Click(object sender, RoutedEventArgs e)
        {
            gridMain.Children.Remove(showPage);
            showPage = _pageBacklog;
            gridMain.Children.Add(showPage);
            
        }

        private void menuItemSprint_Click(object sender, RoutedEventArgs e)
        {
            wndAdminstrator _wndAdmin=new wndAdminstrator();
            _wndAdmin.Show();
        }
    }
}